package com.cangxuan.manage.controller;


import com.cangxuan.manage.annotation.Check;
import com.cangxuan.manage.annotation.check.Max;
import com.cangxuan.manage.annotation.check.NotNull;
import com.cangxuan.manage.bean.Page;
import com.cangxuan.manage.entity.User;
import com.cangxuan.manage.entity.UserLog;
import com.cangxuan.manage.service.IUserLogService;
import com.cangxuan.manage.service.IUserService;
import io.swagger.annotations.*;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Author:程佳逸
 * 用户日志相关接口
 */
@Api(tags = "用户日志相关接口")
@RestController
@RequestMapping("userLog")
public class UserLogController extends BaseController{
IUserLogService userLogService;
@Autowired
public void setUserService(IUserLogService userLogService) {
    this.userLogService = userLogService;
}
    @Data
    @ApiModel("用户日志分页查询body")
    public static class UserLogPageBody{
        @ApiModelProperty("页码，从1开始")
        @NotNull(message = "请传递pageIndex")
        Integer pageIndex;
        @ApiModelProperty("页大小，就是每页查询的数量，最大为50条")
        @Max(value = 50, message = "pageSize不能大于50")
        Integer pageSize = 10;
        @ApiModelProperty("用户id")
        int userId;
    }

    @PostMapping
    @ApiOperation("用户日志分页查询")
    public Object page(@Check @RequestBody UserLogController.UserLogPageBody userLogPageBody) {
        Page<UserLog> userLogPage = userLogService.page(userLogPageBody.getPageIndex(),
                userLogPageBody.getPageSize(),
                userLogPageBody.getUserId());
        return success(userLogPage);
    }
}
